/*
Building a Clean and Loyal State: The Strategic Dilemma of an Anti-corruption Campaign Under One-Party Rule
Authors: Tianyang Xi, Yang Yao and Qian Zhang
Date: Oct, 30, 2023
Stata Version 14.0
Operating System: Micrsoft Windows 10
*/

clear
set more off
capture log close

*-------------------------------Table A3------------------------------------*
use "investigation_2013_2021.dta" ,clear

*column (1)-(4)
probit lm performance connectionc_yes xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location, cluster(location)
probit lm performance connectionc_yes jiao1_p_yes xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location , cluster(location)
probit lm performance connectionc xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location ,cluster(location)
probit lm performance connectionc jiao1_p xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location,cluster(location)

*calculate marginal effects in column (1):
probit lm performance connectionc_yes xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location , cluster(location)
margins, dydx(performance connectionc_yes)  //calculate marginal effects of connection and performance

*calculate marginal effects in column (2):
probit lm performance connectionc_yes jiao1_p_yes xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location , cluster(location)
margins, dydx(performance connectionc_yes)  //calculate marginal effects of connection and performance
probit lm performance connectionc_yes jiao1_p_yes xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021, cluster(location)
inteff lm performance connectionc_yes jiao1_p_yes xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021,  savedata("interaction_effect_A3_2",replace) savegraph1("interaction_effect_A3_2_1",replace) savegraph2("interaction_effect_A3_2_2",replace)
*Average marginal effect of interaction:
*egen x=mean(_probit_ie) //x=-0.31

*calculate marginal effects in column (3):
probit lm performance connectionc xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location ,cluster(location)
margins, dydx(performance connectionc)  //calculate marginal effects of connection and performance

*calculate marginal effects in column (4):
probit lm performance connectionc jiao1_p xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 i.location,cluster(location)
margins, dydx(performance connectionc)  //calculate marginal effects of connection and performance
probit lm performance connectionc jiao1_p xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021 ,cluster(location)
inteff lm performance connectionc jiao1_p xs_2014-xs_2021 college_yes mini_nat gender year2014-year2021,savedata("interaction_effect_A3_4",replace) savegraph1("interaction_effect_A3_4_1",replace) savegraph2("interaction_effect_A3_4_2",replace)
*Average marginal effect of interaction:
*egen x=mean(_probit_ie) //x=-0.06

